package com.ag.work.dao;

import java.sql.SQLException;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.ag.dao.TbProposeDAO;

public class ProposeDAO extends TbProposeDAO {
	private static final Log log = LogFactory.getLog(ProposeDAO.class);

	public List find(String UId) {
		log.info("打印出：UId----" + UId);
		log.debug("getting TbPropose by id: " + UId);
		try {
			String hql = "from TbProposeRecord ps join fetch ps.tbPropose where ps.id.UId = ?";
			List list = getHibernateTemplate().find(hql, UId);
			log.info("-------" + list);
			log.info("list----" + list.get(0));
			return list;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}

	}

	public List find1(final String cql) throws Exception {
		return getHibernateTemplate().executeFind(new HibernateCallback() {
			public Object doInHibernate(Session s) throws HibernateException,
					SQLException {
				Query query = s.createQuery(cql);				
				List list = query.list();
				return list;
			}
		});
	}
}
